package com.shlh.saas.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shlh.saas.entity.WorkbenchStats;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 工作台统计数据Mapper接口
 */
@Mapper
public interface WorkbenchStatsMapper extends BaseMapper<WorkbenchStats> {

    /**
     * 获取用户的工作台统计数据
     * @param userId 用户ID
     * @return 工作台统计数据
     */
    @Select("SELECT * FROM workbench_stats WHERE user_id = #{userId}")
    WorkbenchStats getByUserId(@Param("userId") Long userId);
    
    /**
     * 增加海关数据库搜索次数
     * @param userId 用户ID
     */
    @Update("UPDATE workbench_stats SET customs_search_count = customs_search_count + 1, updated_at = NOW() " +
            "WHERE user_id = #{userId}")
    void incrementCustomsSearchCount(@Param("userId") Long userId);
    
    /**
     * 增加海关数据库导出次数
     * @param userId 用户ID
     */
    @Update("UPDATE workbench_stats SET customs_export_count = customs_export_count + #{count}, updated_at = NOW() " +
            "WHERE user_id = #{userId}")
    void incrementCustomsExportCount(@Param("userId") Long userId, @Param("count") Integer count);
    
    /**
     * 增加全球企业库搜索次数
     * @param userId 用户ID
     */
    @Update("UPDATE workbench_stats SET enterprise_search_count = enterprise_search_count + 1, updated_at = NOW() " +
            "WHERE user_id = #{userId}")
    void incrementEnterpriseSearchCount(@Param("userId") Long userId);
    
    /**
     * 增加全球企业库导出次数
     * @param userId 用户ID
     */
    @Update("UPDATE workbench_stats SET enterprise_export_count = enterprise_export_count + #{count}, updated_at = NOW() " +
            "WHERE user_id = #{userId}")
    void incrementEnterpriseExportCount(@Param("userId") Long userId, @Param("count") Integer count);
    
    /**
     * 增加广交会采购商搜索次数
     * @param userId 用户ID
     */
    @Update("UPDATE workbench_stats SET canton_buyer_search_count = canton_buyer_search_count + 1, updated_at = NOW() " +
            "WHERE user_id = #{userId}")
    void incrementCantonBuyerSearchCount(@Param("userId") Long userId);
    
    /**
     * 增加广交会采购商导出次数
     * @param userId 用户ID
     */
    @Update("UPDATE workbench_stats SET canton_buyer_export_count = canton_buyer_export_count + #{count}, updated_at = NOW() " +
            "WHERE user_id = #{userId}")
    void incrementCantonBuyerExportCount(@Param("userId") Long userId, @Param("count") Integer count);
    
    /**
     * 增加广交会参展商搜索次数
     * @param userId 用户ID
     */
    @Update("UPDATE workbench_stats SET canton_exhibitor_search_count = canton_exhibitor_search_count + 1, updated_at = NOW() " +
            "WHERE user_id = #{userId}")
    void incrementCantonExhibitorSearchCount(@Param("userId") Long userId);
    
    /**
     * 增加广交会参展商导出次数
     * @param userId 用户ID
     */
    @Update("UPDATE workbench_stats SET canton_exhibitor_export_count = canton_exhibitor_export_count + #{count}, updated_at = NOW() " +
            "WHERE user_id = #{userId}")
    void incrementCantonExhibitorExportCount(@Param("userId") Long userId, @Param("count") Integer count);
    
    /**
     * 增加LinkedIn获客搜索次数
     * @param userId 用户ID
     */
    @Update("UPDATE workbench_stats SET linkedin_search_count = linkedin_search_count + 1, updated_at = NOW() " +
            "WHERE user_id = #{userId}")
    void incrementLinkedInSearchCount(@Param("userId") Long userId);
    
    /**
     * 增加LinkedIn获客搜索次数（兼容小写方法名）
     * @param userId 用户ID
     */
    @Update("UPDATE workbench_stats SET linkedin_search_count = linkedin_search_count + 1, updated_at = NOW() " +
            "WHERE user_id = #{userId}")
    void incrementLinkedinSearchCount(@Param("userId") Long userId);
    
    /**
     * 增加LinkedIn获客导出次数
     * @param userId 用户ID
     */
    @Update("UPDATE workbench_stats SET linkedin_export_count = linkedin_export_count + #{count}, updated_at = NOW() " +
            "WHERE user_id = #{userId}")
    void incrementLinkedInExportCount(@Param("userId") Long userId, @Param("count") Integer count);
    
    /**
     * 增加LinkedIn获客导出次数（兼容小写方法名）
     * @param userId 用户ID
     * @param count 导出数量
     */
    @Update("UPDATE workbench_stats SET linkedin_export_count = linkedin_export_count + #{count}, updated_at = NOW() " +
            "WHERE user_id = #{userId}")
    void incrementLinkedinExportCount(@Param("userId") Long userId, @Param("count") Integer count);
    
    /**
     * 增加Facebook获客搜索次数
     * @param userId 用户ID
     */
    @Update("UPDATE workbench_stats SET facebook_search_count = facebook_search_count + 1, updated_at = NOW() " +
            "WHERE user_id = #{userId}")
    void incrementFacebookSearchCount(@Param("userId") Long userId);
    
    /**
     * 增加Facebook获客导出次数
     * @param userId 用户ID
     */
    @Update("UPDATE workbench_stats SET facebook_export_count = facebook_export_count + #{count}, updated_at = NOW() " +
            "WHERE user_id = #{userId}")
    void incrementFacebookExportCount(@Param("userId") Long userId, @Param("count") Integer count);
    
    /**
     * 增加Twitter获客搜索次数
     * @param userId 用户ID
     */
    @Update("UPDATE workbench_stats SET twitter_search_count = twitter_search_count + 1, updated_at = NOW() " +
            "WHERE user_id = #{userId}")
    void incrementTwitterSearchCount(@Param("userId") Long userId);
    
    /**
     * 增加Twitter获客导出次数
     * @param userId 用户ID
     */
    @Update("UPDATE workbench_stats SET twitter_export_count = twitter_export_count + #{count}, updated_at = NOW() " +
            "WHERE user_id = #{userId}")
    void incrementTwitterExportCount(@Param("userId") Long userId, @Param("count") Integer count);
    
    /**
     * 增加智能搜邮次数
     * @param userId 用户ID
     */
    @Update("UPDATE workbench_stats SET intelligent_search_count = intelligent_search_count + 1, updated_at = NOW() " +
            "WHERE user_id = #{userId}")
    void incrementIntelligentSearchCount(@Param("userId") Long userId);
    
    /**
     * 增加邮件反查次数
     * @param userId 用户ID
     */
    @Update("UPDATE workbench_stats SET email_reverse_count = email_reverse_count + 1, updated_at = NOW() " +
            "WHERE user_id = #{userId}")
    void incrementEmailReverseCount(@Param("userId") Long userId);
    
    /**
     * 增加域名反查次数
     * @param userId 用户ID
     */
    @Update("UPDATE workbench_stats SET domain_lookup_count = domain_lookup_count + 1, updated_at = NOW() " +
            "WHERE user_id = #{userId}")
    void incrementDomainLookupCount(@Param("userId") Long userId);
    
    /**
     * 增加社媒反查次数
     * @param userId 用户ID
     */
    @Update("UPDATE workbench_stats SET social_media_lookup_count = social_media_lookup_count + 1, updated_at = NOW() " +
            "WHERE user_id = #{userId}")
    void incrementSocialMediaLookupCount(@Param("userId") Long userId);
} 